package jeye.listeners.basic;

import java.awt.image.BufferedImage;

import jeye.events.MotionDetectionEvent;
import jeye.listeners.MotionDetectionListener;
import jeye.utils.FileUtils;

public class SaveSingleFrameListener implements MotionDetectionListener {
	
	public void onMotionDetection(MotionDetectionEvent event) {
		if(event.isMotionDetected()) {
			BufferedImage frameImage = event.getFrameImage();
			String directoryName = FileUtils.createEventFramesDirectory(event.getEventUUID());

			FileUtils.saveFrame(frameImage, directoryName, String.valueOf(event.getTimestamp()));
		}
	}
	
}
